import {
  request_post,
  request_get,
  request_put,
  request_delete
} from "services/common/request";
/**
 * 获取场景列表
 * @param {Object} data
 * @param {String} data.name - 选填 名称
 * @param {String} data.pageStart
 * @param {String} data.pageOffset
 * @param {String} data.pageNum
 */
export function getList(data = {}) {
  return request_get("/categoryRelation/selectCategoryRelationAndEquip", data);
}

/**
 * 获取场景
 * @param {Object} data
 * @param {String} data.name - 选填 名称
 * @param {String} data.interfaceIds
 * @param {String} data.name
 */
export async function save(ids, pids) {
  return Promise.all([
    request_post("/categoryRelation/sureCategory", { ids: ids }),
    request_post("/equipment/sureEquip", { ids: pids })
  ]);
}

/**
 * 前台获取监控列表
 * @param {Object} data
 */
export async function frame() {
  return request_post("//equipment/selectEquipIsShow");
}
/**
 * 前台获取趋势列表
 * @param {Object} data
 */
export async function trend(ids, pids) {
  return request_post("/graph/lookGraph").then(res => {
    res.data = res.data.map(element => ({
      ...element,
      yArr: element.yArr.map(item => Math.abs(Number(item)))
    }));
    return res;
  });
}
/**
 * 前台获取趋势列表
 * @param {Object} data
 */
export async function realTimeInfo(id) {
  return request_post("/equipment/realTimeInfoV2", { id });
}
